//function toggle(e) {
  //console.log('callback ran');
  //e.target.classList.toggle('danger');
//}

//document.querySelector('button').addEventListener('click', toggle);


const posts = [
  {title: 'Nobody Care Me', body: 'So Who Care Me'},
  {title: 'Nobody Care Me2', body: 'So Who Care Me2'},
];

function createPost(post, cb) {
  setTimeout(() => {
    posts.push(post);
    cb();
  }, 2000);
}

function getPosts() {
  setTimeout(() => {
    posts.forEach(function (post) {
      const div = document.createElement('div');
      div.innerHTML = `<strong>${post.title}</strong> - ${post.body}`;
      document.querySelector('#posts').appendChild(div);
    });
  }, 1000);
}

createPost({title: 'Nobody Care Me3', body: 'So Who Care Me3' }, getPosts);

//getPosts();